
 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" size="small">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
 		<div class="bt">归还</div>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="归还数量">
 				<el-input v-model="form.wghsl"  :readonly="true"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
      <el-form-item label="归还说明">
        <el-input v-model="form.tlyy" type="textarea" :rows="2" placeholder="请输入" class="select-block"></el-input>
      </el-form-item>
 		</el-form>
 		<el-button type="primary" class="submit" @click="submit">归还</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 				form: {
					 wghsl :'',
					 tlyy :' ',
					 lyckid :'',
 					 id:'',
 					 ckmc:''
 				},
 				kkk:'',
 				 comboxlistck:[],
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
  		  this.getcomboxlistck();
          this.loadinfo();
 		},
 		methods: {
 			loadinfo(){
 				 var logininfo = JSON.parse(localStorage.logininfo) ;
         var params3 = qs.stringify({
           xxid:logininfo.xxid,
           yhid:logininfo.id,
           id:this.form.id
						});
 				 this.axios.post(this.$store.state.api+'wplytl/info',params3)
         .then( res =>  {
 							this.form=res.data.data
 					 }).catch(res => {
 						 this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'info', cancel: true });
 					 })
 			},
 			 submit() {
 				//检测
 				this.$store.state.loading = true;
 				//装载数据
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id+'',
 						tlsl: this.form.wghsl+'',
 						tlyy: this.form.tlyy+'',
 						tlckid:this.form.lyckid+'',
 						yhid: logininfo.id+'',
 						xxid: logininfo.xxid+''
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'wplytl/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$message.success(res.data.msg);
 								this.$store.state.loading = false;
 							} else {
 								this.$message.warning(res.data.msg)
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							this.$message.danger("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			getcomboxlistck(){
        var logininfo = JSON.parse(localStorage.logininfo) ;
        var params3 = qs.stringify({
          yhid:logininfo.id,
          xxid:logininfo.xxid,
          pageindex: 1,
          pagesize: 1000
			  });
          this.searchLoading = true;
          this.axios.post(this.$store.state.api + 'cku/list',params3)
          .then( res => {
              let data = res.data.data;
              let list = data.list;
              this.comboxlistck=list;
          }).catch( res => {
              this.searchLoading = false;
          })
        },

 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 	.wrap {
 		text-align: center;
 	}
 	.bt{
		position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			background: #50BFFF;
			left: 0;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
	}
 	.form {
 		text-align: left;
 		margin-top: 20px;
 	}
 	.close{
				z-index: 10;
				position: absolute;
		}
 	.input {
             width: 300px;
             display: inline-block;
         }
 	.select-block {
 		display: block;
 	}
 	.submit {
 		width: 120px;
 	}
 </style>
